package cn.hust.springboot.service.impl;

import cn.hust.springboot.bean.Contract;
import cn.hust.springboot.bean.ContractExample;
import cn.hust.springboot.bean.DeptExample;
import cn.hust.springboot.mapper.ContractMapper;
import cn.hust.springboot.service.IContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContractServiceImpl implements IContractService {
    @Autowired
    private ContractMapper contractMapper;

    @Override
    public Contract getContractById(Integer id) {
        return contractMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Contract> getContractAndEmp() {
        return contractMapper.getContractAndEmp();
    }

    @Override
    public List<Contract> getAllContracts() {
        ContractExample example = new ContractExample();
        ContractExample.Criteria criteria = example.createCriteria();
        criteria.getAllCriteria();
        return this.contractMapper.selectByExample(example);
    }

    @Override
    public int deleteContractById(Integer id) {
        return contractMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int addContract(Contract contract) {
        return contractMapper.insert(contract);
    }

    @Override
    public int updateContract(Contract contract) {
        return contractMapper.updateByPrimaryKey(contract);
    }

    @Override
    public List<Contract> query(String name) {
        return contractMapper.query(name);
    }
}
